<?php  
        session_start();
        require_once '../host_config.php';
        require_once '../Model/mysql.php';
        if (!isset($_SESSION['shopid']) && isset($_SESSION['flag'])) {
            echo "<script language='javascript'>";
            echo "alert('You have no permission to read this page!');";
            echo "history.back();";
            echo "</script>";
            header("location:../login.php");
        }else if($_SESSION['flag'] == "2") {
        	$shopid = $_GET['id'];
        }else if($_SESSION['shopid'] != $_GET['id']) {
        	header("location:select.php?id=".$_SESSION['shopid']);
        }
        else {
        	$mysql = new MySQL();
        	$link = $mysql->connect($mysql_host, $mysql_user, $mysql_passwd, $mysql_db);
			//$u_id = $_GET['id'];
			//$u_id = mysql_real_escape_string($u_id);
			$shopid = $_SESSION['shopid'];
        }
?>
<!DOCTYPE html>
<html>
<head>
	<meta name="viewport" content="width=device-width; text/html; charset=utf-8" http-equiv="Content-Type">
	<title>登入系統</title>
	<link href="../mobile.css" rel="stylesheet" type="text/css">
	<style type="text/css">
	</style>
</head>
<body>
	<div id="banner">功能選擇
		<div id="home">
			<a href="select.php?id=<?php echo $shopid;?>">
			<img alt="" class="auto-style1" height="40" src="../pic/home.png" width="40"></a>
		</div>
		<div id="logout">
			<a href="../logout.php">
			<img alt="" class="auto-style1" height="41" src="../pic/logout.png" width="41"></a>
		</div>
	</div>
	<div id="content">
		<br/>
		<p>第一次登入請先新增餐廳資料</p>
		<div id="button_z">
			<a href="../first_use/main.php?id=<?php echo $shopid;?>">餐廳資料新增</a>		
		</div>
		<?php     				
           // $sql = "SELECT `shopid` FROM Shops WHERE `fullname` = (SELECT `shopname` FROM LoginUser WHERE `loginid` = '$u_id')";
            //$result = $mysql->query_row($sql, $link);
			if($shopid != 0) {
				//$shopid = $result[0];    
				echo '<div id="button_z">';       
				echo'<a href=test.php?id='.$shopid.'>餐廳資料查詢</a>';
				echo '</div>';
			}else {
				echo "<script language='javascript'>";
    			echo "alert('第一次登入請先新增餐廳資料!');";
    			//echo "history.back();";
    			echo "</script>";
			}
		?>
		<p></p>	
		<hr>
		<br/>		
	</div>
</body>
</html>

